home *** CD-ROM | disk | FTP | other *** search
- Path: newshub.ccs.yorku.ca!news
- From: KuMan <" yu133496"@yorku.ca>
- Newsgroups: comp.lang.c++
- Subject: character strings read-in problem!
- Date: Wed, 28 Feb 1996 17:56:18 -0500
- Organization: York University, Ontario, Canada
- Message-ID: <4h2mkr$5au@sunburst.ccs.yorku.ca>
- NNTP-Posting-Host: kirk07.slip.yorku.ca
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win95; I)
-
- hello all:
-
- I'm trying to read in strings from a file and put them in an array of 26 different cells
- according to their order alphabetically.
-
- #include <stdio.h>
- #include <stdlib.h>
-
- void main(){
-
- FILE *input;
- char name[20];
- char *stop_word[26];
-
- input = fopen("QQ.txt", "r");
- while(!feof(input)){
- fscanf(input, "%s", name);
- stop_word[((name[0] >= 97)? name[0]-96 : name[0]%64)] = name;
- }
- printf("%s \n", stop_word[1]);
- printf("%s \n", stop_word[3]);
- }
- fclose(input);
- }
-
- "QQ.txt"
- apple boy cow duck eagle
-
- But both of the 2 print statements print out "eagle", they suppose to be "apply" and "boy"
- accordingly.........
-
- what went wrong???????
-
- Thank You
- Kuman
- yu133496@yorku.ca
-